package com.szh.zuoye;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MyDBHelper extends SQLiteOpenHelper {
    public MyDBHelper(@Nullable Context context) {
        super(context, "users.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table user(_id integer primary key autoincrement,username varchar(10) not null, userPwd varchar(20))";
        db.execSQL(sql);
        String sql2 = "insert into user(username,userPwd)values(?,?)";
        db.execSQL(sql2, new Object[]{"沈", "123456"});
        db.execSQL(sql2, new Object[]{"陈", "120"});
        db.execSQL(sql2, new Object[]{"乐", "110"});
        db.execSQL(sql2, new Object[]{"王", "119"});
        db.execSQL(sql2, new Object[]{"邵", "114"});
        db.execSQL(sql2, new Object[]{"叶", "12315"});

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
